<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-09-26 10:03
 *
 * Version: 2.0
 */

namespace App\Models;


use Illuminate\Database\Eloquent\Model;

class AmountFlow extends Model
{
	protected $table = "amount_flow";
	protected $guarded = [];


	public function order(){
		if($this->category == 1) {
			return $this->hasOne(Order::class, 'id', 'link_id');
		} else if($this->category == 2){
			return $this->hasOne(MemberCardFlow::class, 'id', 'link_id');
		} else if($this->category == 3){
			return $this->hasOne(GoodsOrder::class, 'id', 'link_id');
		}
	}

	public function user(){
		return $this->hasOne(User::class, 'id','user_id');
	}
}